package com.my.db;

import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author timo 2021/3/12
 */
@Configuration
@MapperScan({"com.my.**.mapper.**"})
//@MapperScan("com.my.db.test") //mybaits的mapper
@EnableConfigurationProperties({MybatisPlusProperties.class})
@PropertySource("classpath:/defal-mybatis.yml")
@EnableTransactionManagement
public class MybatisPlusConfiguration {
    /**
     * mybatis plus分页插件配置
     * @return
     */
    @Bean
    @ConditionalOnClass(value = {PaginationInterceptor.class})
    public PaginationInterceptor paginationInterceptor(){
        return new PaginationInterceptor();
    }

//    @Bean
//    @ConditionalOnProperty(
//            value = {"blade.mybatis-plus.sql-log"},
//            matchIfMissing = true
//    )
//    public SqlLogInterceptor sqlLogInterceptor() {
//        return new SqlLogInterceptor();
//    }
//
//    @Bean
//    public ISqlInjector sqlInjector() {
//        return new BladeSqlInjector();
//    }
//
//    public MybatisPlusConfiguration() {
//    }
}
